<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>获得前后兄弟节点</title>
    <link rel="stylesheet" href="css/7-2.css">
</head>

<body>
    <p>我喜欢的水果:</p>
    <ul id="fruit">
        <li>百香果</li>
        <li>山竹</li>
        <li>火龙果</li>
        <li>猕猴桃</li>
    </ul>
    <script>
        var fruit=document.getElementById('fruit');

        //获取ul节点的内容
        var text=fruit.innerHTML;
        console.log(text);

        //修改ul节点的内容
        //fruit.innerHTML=text+"<li>柠檬</li>";

        var innerText=fruit.innerText;
        console.log(innerText);
        var textContent=fruit.textContent;
        console.log(textContent);
    
    </script>
</body>

</html>